package org.snia.cdmi.util;

public class ParameterUtils {

	public static void validateContainerName(String name) throws IllegalArgumentException {
        if (name == null)
            throw new IllegalArgumentException("Container name cannot be null");

        if (!name.toLowerCase().equals(name))
            throw new IllegalArgumentException("Container name should not contain uppercase characters");

        if (name.contains("_"))
            throw new IllegalArgumentException("Container name should not contain '_'");

        if (name.contains("!") || name.contains("@") || name.contains("#"))
        	throw new IllegalArgumentException("Container name contains illegal characters");

        if (name.length() < 3 || name.length() > 63)
            throw new IllegalArgumentException("Container name should be between 3 and 63 characters long");

        if (name.endsWith("-") || name.endsWith("."))
            throw new IllegalArgumentException("Container name should not end with '-' or '.'");

        if (name.contains(".."))
            throw new IllegalArgumentException("Container name should not contain two adjacent periods");

        if ( name.contains("-.") ||
        		name.contains(".-") )
            throw new IllegalArgumentException("Container name should not contain dashes next to periods");
	}
}
